<template>
    <div class="fillcontain">
        <el-form :inline="true" ref="form" :model="form" label-width="80px">
            <el-form-item label="推荐人">
                <el-input v-model="form.phone"></el-input>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="onSubmit">查询</el-button>
            </el-form-item>

            <!-- <el-form-item style="float:right">
                <el-button type="primary" icon="el-icon-plus" @click="onAdd">新增</el-button>
            </el-form-item> -->
        </el-form>

        <div class="table_container">
            <el-table :data="tableData" highlight-current-row style="width: 100%">
                <el-table-column type="index" width="60"></el-table-column>
                <el-table-column property="tjr" label="推荐人" width="100"></el-table-column>
                <el-table-column property="tjhys" align="right" label="推荐会员数" width="100"></el-table-column>
                <el-table-column property="czbs" align="right" label="充值笔数" width="100"></el-table-column>
                <el-table-column property="czje" align="right" label="充值金额" width="100"></el-table-column>
                <el-table-column property="czsjzfe" align="right" label="实际支付额" width="100"></el-table-column>
                <el-table-column property="fkdw" label="发卡单位" width=""></el-table-column>
            </el-table>
            <div class="Pagination" style="text-align: left;margin-top: 10px;">
                <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage" :page-sizes="[10, 20, 30, 40]" :page-size="100" layout="total, sizes, prev, pager, next, jumper" :total="count">
                </el-pagination>
            </div>
        </div>

    </div>
</template>
<style>
.demo-table-expand {
    font-size: 0;
}
.demo-table-expand label {
    width: 132px;
    color: #99a9bf;
}
.demo-table-expand .el-form-item {
    margin-right: 0;
    margin-bottom: 0;
    width: 50%;
}
</style>

<script>
import headTop from '../components/headTop'
import { getUserList, getUserCount } from '@/api/getData'
import { dataWay, insertFrozenBill, frozen } from '@/api/getData'
import { getStore } from '@/config/mUtils'
export default {
    data () {
        return {
            form: {
                phone: '',
                cardUnitId: '0'
            },
            unitArr: ['佳惠'],
            czlxArr: ['冻结', '解冻'],
            statusArr: ['保存', '审核'],//状态,// 0--保存，1--审核

            dialogFormVisible: false,
            fullscreenLoading: false,
            addform: {
                accountId: '',
                cardUnitId: '0',
                czlx: '',
                hyId: '',
                reason: '',
                token: '',
            },
            formLabelWidth: '120px',
            tableData: [

            ],
            currentRow: null,
            offset: 0,
            limit: 20,
            count: 0,
            currentPage: 1,
        }
    },
    components: {
        headTop,
    },
    created () {
        this.initData();
    },
    methods: {
        async initData () {
            try {
                this.QueryTJ();
            } catch (err) {
                console.log('获取数据失败', err);
            }
        },
        handleSizeChange (val) {
            console.log(`每页 ${val} 条`);
            this.currentPage = val;
            this.getCustomers()
        },
        handleCurrentChange (val) {
            this.currentPage = val;
            this.offset = (val - 1) * this.limit;
            this.getCustomers()
        },
        async QueryTJ () {
            const res = await dataWay({
                apiid: 'QueryTJ',
                cztjr: this.form.phone,
                // token: getStore('token')
            });
            console.log(res.retcode);

            if (res.retcode === '00') {
                this.tableData = [];
                this.count = res.data.length;

                res.data.forEach(item => {
                    // item.czlx = this.czlxArr[item.cardUnitId]
                    // item.status = this.statusArr[item.cardUnitId]
                    this.tableData.push(item)
                })
            }

            if (res.retcode == '06') {
                console.log(2222);
                this.$notify({
                    title: '警告',
                    message: '重新登录',
                    showClose: false,
                    type: 'warning'
                });
                this.$router.push('/')
            }
        },
        // 查询
        onSubmit () {
            console.log('ddd');
            this.QueryTJ()
        },




    },
}
</script>

<style lang="less">
@import "../style/mixin";
.table_container {
    padding: 20px;
}
</style>
